<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./lib/vue_2.5.22.js"></script>
  <script src="./lib/vue-router_3.0.2.js"></script>
</head>

<body>

  <div id="app">

    <router-link to='/shoplist/1'>商品列表</router-link>
    <router-link to='/shoplist/2'>商品列表</router-link>
    <router-link to='/shoplist/3'>商品列表</router-link>
    <router-link :to='{name:"ShopList",params:{id:4}}'>商品列表</router-link>
    <router-link to='/register'>Register</router-link>

    <router-view></router-view>
  </div>

  <script>

    var Login = {
      template: `
        <h2>商品详情 -- 商品id：{{$route.params.id}}</h2>
      `
    }

    var Register = {
      template: `
        <h2>注册</h2>
      `
    }


    var router = new VueRouter({
      routes: [
        { path: '/', redirect: '/shoplist/1' },
        { path: '/shoplist/:id', component: Login, name: 'ShopList' },
        { path: '/register', component: Register, name: 'Register' },
      ]
    })

    var vm = new Vue({
      el: '#app',
      data: {},
      router

    })
  </script>
</body>

</html>